import { apiHttp } from '../../apiHttp';
import Api from '../../../api/person/personController.api';
import CaneerApi from '../../../api/company/comManagerController.api';
import PersonApi from '../../../api/common/commonController.api'; // 人物职务
import { JsonResult, PersonDto, ComManagerDto, } from '../../../api/Interface';
import { PersonSearchDto, PersonRelativeDto } from './personInterface';


export default {
    // 获取人物信息
    getPersonDetail: async (id: string): Promise<PersonDto> => {
        const res: JsonResult = await apiHttp(Api.getPerson, {personId: id});
        return res.data;
    },
    // 新建人物
    savePerson: async (person: PersonDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.savePerson, person);
        return res;
    },
    // 修改人物
    updatePerson:  async (person: PersonDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.updatePerson, person);
        return res;
    },
    // 获取列表上方的统计数据
    getPersonCount: async (): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.getPersonCountInfo, '');
        return res.data;
    },
    // 人物列表
    getPersonList: async (personSearch: PersonSearchDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.personPage, personSearch);
        return res;
    },
    // 删除人物信息
    deletePerson: async (personId: string): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.deletePersonById, {id: personId});
        return res;
    },
    // 保存职业履历
    saveCareer: async (career: ComManagerDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(CaneerApi.saveComManager, career);
        return res;
    },
    // 根据人物id获取职业履历
    getCaneerList: async (id: string): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(CaneerApi.comManagerList, {personId: id});
        return res;
    },
    // 获取人物关联关系 
    getPersonRelationByPersonId: async (personSearch: PersonRelativeDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.getPersonRelationByPersonId, personSearch);
        return res;
    },
    // 删除人物信息 验证是否有关联数据
    getDeletePersonCheck: async (id: string): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.getDeletePersonCheck, {personsId: id});
        return res;
    },
    // 获取人物职务列表
    getPersonPosition: async (tit: string): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(PersonApi.getDutiesLevel, {title: tit});
        return res;
    },
    // 排序
    personSort: async (list: number[]): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(CaneerApi.orderByProductResumes, {idList: list});
        return res;
    },
};